use generator_engine::tera::TeraEngine;
use model_graph_common::transport::http::{http_get, http_post};
use model_graph_types::assistant::prompts::PromptTemplateItem;
use model_graph_types::modeling::assistant::{ModelProvider, ModelProviderSetting, ModelType};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::sync::{Arc, Mutex};

use model_graph_types::{
    container::workflow::{
        VideoGeneratorStatement, WorkflowBlockExecuteResult, WorkflowBlockExecuteResultBuilder,
        WorkflowBlockExecuteResultStatus,
    },
    generator::CodeGenerator,
    modeling::Value,
};

use crate::workflow::context::{Getter, WorkflowContext};

pub async fn execute(
    statement: &VideoGeneratorStatement,
    context: Arc<Mutex<WorkflowContext>>,
) -> anyhow::Result<WorkflowBlockExecuteResult> {
    let result = _execute(statement, context).await;

    match result {
        Ok(v) => Ok(WorkflowBlockExecuteResultBuilder::default()
            .status(WorkflowBlockExecuteResultStatus::Succeeded)
            .source_handle("source")
            .result(v)
            .build()?),
        Err(err) => Ok(WorkflowBlockExecuteResultBuilder::default()
            .status(WorkflowBlockExecuteResultStatus::Succeeded)
            .source_handle("fail-branch")
            .build()?),
    }
}

pub async fn _execute(
    statement: &VideoGeneratorStatement,
    context: Arc<Mutex<WorkflowContext>>,
) -> anyhow::Result<HashMap<String, Value>> {
    let mut result: HashMap<String, Value> = HashMap::new();
    //
    Ok(result)
}
